package com.bungarus.om.controller;

import com.bungarus.om.model.BungarusError;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;


public abstract class BungarusController {
    @ExceptionHandler({IllegalArgumentException.class, Exception.class})
    @ResponseStatus(HttpStatus.BAD_REQUEST)
    public BungarusError dealException(Exception e) {
        BungarusError error = BungarusError.newBuilder()
                .message(e.getMessage())
                .build();
        return error;
    }
}
